package com.qeado.content.service.impl;

import java.util.List;
import java.util.UUID;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.qeado.content.dao.AdManageDao;
import com.qeado.content.model.AdManage;
import com.qeado.content.model.AdTypeCode;
import com.qeado.content.service.AdManageService;

@Service
public class AdManageServiceImpl implements AdManageService {

	@Autowired
	private AdManageDao adManageDao;

	public List<AdTypeCode> getAllAdTypeList() {
		return this.adManageDao.getAllAdTypeList();
	}

	@Override
	public List<AdTypeCode> getAllAdLocationList() {
		return this.adManageDao.getAllAdLocationList();
	}

	public List<AdManage> getAdByTypeAndDesc(AdManage ad) {
		return this.adManageDao.getAdByTypeAndDesc(ad);
	}

	public void saveNewAd(AdManage ad) {
		if(ad.getId() == null || "".equals(ad.getId())){
			ad.setId(UUID.randomUUID().toString());
			adManageDao.insertAdManage(ad);
		}else {
			adManageDao.updateAdManage(ad);
		}
	}

	@Override
	public void deleteAdManageById(String id) {
		this.adManageDao.deleteAdManageById(id);
	}

	@Override
	public AdManage selectAdManageById(String id) {
		return this.adManageDao.selectAdManageById(id);
	}

	@Override
	public AdManage getAdContent(String id) {
		return this.adManageDao.getAdContent(id);
	}
}
